<!-- 发布提示 -->
<script setup>
import { toRefs, onMounted } from 'vue';
import { ElMessageBox } from 'element-plus';

const props = defineProps({
  messageBoxShow: Boolean,
  messageText: String,
  messageBoxType: String,
});
const { messageBoxShow, messageText, messageBoxType } = toRefs(props);
const emit = defineEmits(['handleMessageBox']);

onMounted(() => {
  if (messageBoxShow.value && messageBoxType.value == '发布') {
    ElMessageBox.confirm(`${messageText.value}`, '提示', {
      confirmButtonText: '发布',
      cancelButtonText: '再想一想',
      customClass: 'message-logout',
    })
      .then(() => {
        emit('handleMessageBox', true);
      })
      .catch((e) => {
        emit('handleMessageBox', false);

        return e;
      });
  }

  if (messageBoxShow.value && messageBoxType.value == '删除') {
    ElMessageBox.confirm(`${messageText.value}`, '提示', {
      confirmButtonText: '删除',
      cancelButtonText: '再想一想',
      customClass: 'message-delete',
    })
      .then(() => {
        emit('handleMessageBox', true);
      })
      .catch((e) => {
        emit('handleMessageBox', false);

        return e;
      });
  }

  if (messageBoxShow.value && messageBoxType.value == '保存') {
    ElMessageBox.confirm(`${messageText.value}`, '提示', {
      confirmButtonText: '保存',
      cancelButtonText: '不保存',
      customClass: 'message-logout-save',
    })
      .then(() => {
        emit('handleMessageBox', true);
      })
      .catch((e) => {
        emit('handleMessageBox', false);

        return e;
      });
  }
});
</script>
<template>
  <div></div>
</template>

<style lang="scss">
.message-logout {
  width: 450px;
  height: 180px !important;
  border-radius: 10px;
  .el-message-box__header {
    padding-left: 20px;
    .el-message-box__title {
      color: $base-color;
      font-weight: 600;
      font-size: 16px;
      text-align: left;
    }
  }
  .el-message-box__content {
    .el-message-box__container {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-top: 10px;
      margin-bottom: 10px;

      .el-message-box__message {
        color: $base-color;
        font-weight: 400;
        font-size: 14px !important;

        p {
          font-size: 16px !important;
        }
      }
    }
  }
  .el-message-box__btns {
    ustify-content: flex-end;
    .el-button {
      width: 65px;
      height: 32px;
      color: $base-button-color-info;
      background-color: $base-button-background-info;
      border-color: $border-info;
      border-radius: 4px;

      span {
        color: $base-button-color-info;
        font-weight: 400;
        font-size: 14px;
      }
    }
    .el-button--primary {
      margin-left: 36px;
      background-color: $base-button-background-blue;
      border-color: $border-blue;
      span {
        color: $base-color-blue;
      }
    }
  }
}

.message-delete {
  width: 384px;
  height: 164px !important;
  border-radius: 10px;
  .el-message-box__header {
    padding-left: 20px;
    .el-message-box__title {
      color: $base-color;
      font-weight: 600;
      font-size: 16px;
      text-align: left;
    }
  }
  .el-message-box__content {
    .el-message-box__container {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-top: 10px;
      margin-bottom: 10px;

      .el-message-box__message {
        color: $base-color;
        font-weight: 400;
        font-size: 14px !important;

        p {
          font-size: 16px !important;
        }
      }
    }
  }
  .el-message-box__btns {
    ustify-content: flex-end;
    .el-button {
      width: 65px;
      height: 32px;
      color: $base-color-info;
      background-color: $base-button-background-info;
      border-color: $border-info;
      border-radius: 4px;

      span {
        color: $base-color-info;
        font-weight: 400;
        font-size: 14px;
      }
    }
    .el-button--primary {
      margin-left: 36px;
      background-color: $base-button-background-red;
      border-color: $base-button-background-red;
      span {
        color: $base-color-red;
      }
    }
  }
}

.message-submit {
  width: 450px;
  height: 180px !important;
  border-radius: 10px;
  .el-message-box__header {
    padding-left: 20px;
    .el-message-box__title {
      color: $base-color;
      font-weight: 600;
      font-size: 16px;
      text-align: left;
    }
  }
  .el-message-box__content {
    .el-message-box__container {
      display: flex;
      flex-direction: column;
      align-items: flex-start !important;
      margin-top: 10px;
      margin-bottom: 10px;

      .el-message-box__message {
        color: $base-color;
        font-weight: 400;
        font-size: 14px !important;

        p {
          font-size: 16px !important;
        }
      }
    }
  }
  .el-message-box__btns {
    ustify-content: flex-end;
    .el-button {
      width: 65px;
      height: 32px;
      color: #999999;
      background-color: $base-button-background-info;
      border-color: $base-button-background-info;
      border-radius: 4px;

      span {
        color: #999999;
        font-weight: 400;
        font-size: 14px;
      }
    }
    .el-button--primary {
      margin-left: 36px;
      background-color: $base-button-color-blue;
      border-color: $base-button-color-blue;
      span {
        color: $base-color-blue;
      }
    }
  }
}

.message-logout-save {
  width: 384px;
  height: 164px !important;
  border-radius: 10px;
  .el-message-box__header {
    padding-left: 20px;
    .el-message-box__title {
      color: $base-color;
      font-weight: 600;
      font-size: 16px;
      text-align: left;
    }
  }
  .el-message-box__content {
    .el-message-box__container {
      display: flex;
      flex-direction: column;
      align-items: left;
      margin-top: 10px;
      margin-bottom: 10px;

      .el-message-box__message {
        color: $base-color;
        font-weight: 400;
        font-size: 14px !important;

        p {
          font-size: 16px !important;
        }
      }
    }
  }
  .el-message-box__btns {
    ustify-content: flex-end;
    .el-button {
      width: 65px;
      height: 32px;
      color: $base-color-info;
      background-color: $base-button-background-info;
      border-color: $base-button-background-info;
      border-radius: 4px;

      span {
        color: $base-color-info;
        font-weight: 400;
        font-size: 14px;
      }
    }
    .el-button--primary {
      margin-left: 36px;
      background-color: $base-button-background-green;
      span {
        color: $base-color-green;
      }
    }
  }
}
</style>
